package com.sskj.boom.presenter;

import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.boom.bean.MyGuessBean;
import com.sskj.boom.ui.fragment.MyGuessHistoryFragment;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonConverter;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Flowable;


/**
 * @author Hey
 * Create at  2019/06/27
 */
public class MyGuessHistoryPresenter extends BasePresenter<MyGuessHistoryFragment> {

    public Flowable<List<MyGuessBean>> getMyGuessList(int page, int size) {
        return httpService.getMyGuessList(page, size)
                .tag(this)
                .converter(new JsonConverter<HttpData<PageBean<MyGuessBean>>>() {
                })
                .adapt(new FlowableBody<>())
                .map(list -> list.getData().getList())
                .onErrorReturnItem(new ArrayList<>());
    }
}
